﻿using SQLite;
using System;


namespace StockTradTest.Data
{
    //股票列表数据库结构
    public class StockInfo
    {
        [PrimaryKey, AutoIncrement]
        #region 属性
        public int ID { get; set; }
        public string Code { get; set; }
        public string Name { get; set; }
        //上市日期
        public int StartDate { get; set; }
        #endregion
    }
    //股票数据库结构
    public class Stock : IComparable<Stock>
    {
        [PrimaryKey, AutoIncrement]
        #region 属性
        public int ID { get; set; }
        public int Date { get; set; }
        public double OpenPrice { get; set; }
        public double ClosePrice { get; set; }
        public double ChangePrice { get; set; }//涨跌
        public double ChangeRatio { get; set; }//变化率，涨跌幅
        public double LowPrice { get; set; }
        public double HighPrice { get; set; }
        public int TotalHand { get; set; }//总手数
        public double TotalAmount { get; set; }//总量
        public double HandRate { get; set; }//换手率
        #endregion
        public int CompareTo(Stock other)
        {
            if (null == other)
            {
                return 0;//空值比较大，返回1
            }
            return this.Date.CompareTo(other.Date);//升序
            //return other.Date.CompareTo(this.Date);//降序
        }
        public string Info()
        {
            string text = string.Format("ID:{0}\n" +
                "日期:{1}\n" +
                "开盘:{2}\n" +
                "收盘:{3}\n" +
                "最高:{4}\n" +
                "最低:{5}\n" +
                "涨跌:{6}\n" +
                "涨跌幅:{7}\n" +
                "手数:{8}\n" +
                "换手率:{9}%\n" +
                "成交额:{10}\n",
                ID,
                Date.ToString(),
                OpenPrice,
                ClosePrice,
                HighPrice,
                LowPrice,
                ChangePrice,
                ChangeRatio,
                TotalHand,
                HandRate,
                TotalAmount);
            return text;
        }
    }
    //复权信息结构
    public class Rehibilation : IComparable<Rehibilation>
    {
        public int Date { get; set; }
        public double RehabilitationRate { get; set; }

        public int CompareTo(Rehibilation other)
        {
            if (null == other)
            {
                return 1;//空值比较大，返回1
            }
            return this.Date.CompareTo(other.Date);//升序
            //return other.Date.CompareTo(this.Date);//降序
        }
    }
    //实时数据
    public class RealTimeInfo
    {
        public string stockName;
        public double open;
        public double lastClose;
        public double currentPrice;
        public double high;
        public double low;
        public double buy1Price;
        public double sell1Price;
        public double volume;
        public double amount;
        public double buy1volume;
        public double sell1volume;
        public DateTime time;
        public string Info()
        {
            string text = string.Format("名称:{0}\n" +
                "开盘:{1}\n" +
                "昨日收盘:{2}\n" +
                "当前:{3}\n" +
                "最高:{4}\n" +
                "最低:{5}\n" +
                "买一:{6}\n" +
                "卖一:{7}\n" +
                "成交股票股数:{8}\n" +
                "成交股票金额:{9}\n" +
                "买一股数:{10}\n" +
                "卖一股数:{11}\n" +
                "时间:{12}\n",
                stockName,
                open,
                lastClose,
                currentPrice,
                high,
                low,
                buy1Price,
                sell1Price,
                volume,
                amount,
                buy1volume,
                sell1volume,
                time.ToString()
                );
            return text;
        }
    }
}
